#include "image.h"

void Image::Load(std::string filename)
{
    std::map<std::string, sf::Texture>::iterator it;

    it = imageMap.find(filename);

    //Image is not loaded into memory
    if (it == imageMap.end())
    {
        sf::Texture tempImage;
        tempImage.loadFromFile(filename);
        tempImage.setSmooth(false); //Turns off anti-aliasing
        imageMap[filename] = tempImage;
    }
}

sf::Texture& Image::Get(std::string filename)
{
    std::map<std::string, sf::Texture>::iterator it;

    it = imageMap.find(filename);

    if (it == imageMap.end())
    {
        sf::Texture tempImage;
        tempImage.loadFromFile(filename);
        tempImage.setSmooth(false); //Turns off anti-aliasing
        imageMap[filename] = tempImage;
    }

    return imageMap[filename];
}
